<?php

class WBShape extends WBObject { 
	
	public function __construct($options = array()) { 
		parent::__construct($options);
		
		$this->initShape();
	}
	
	public function __destruct() {
		parent::__destruct();
	}	
	
	protected function initShape() { 
		
	}
	
	/**
	 * render shape 
	 * 
	 * @see lib/php/lang/PObject#display()
	 */
	public function display($graphics) { 
		
	}
	
	/**
	 * 포인트가 현재 위치에 있는지 체크 
	 * 
	 * @param int $x
	 * @param int $y
	 * @return bool
	 */
	public function isArea($x, $y) { 

		$_x = $this->getOption('x');
		$_y = $this->getOption('y');
		$_x2 = $_x + $this->getOption('width');
		$_y2 = $_y + $this->getOption('height');
		
		if ($_x <= $x && $x <= $_x2) { 
			if ($_y <= $y && $y <= $_y2) {
				return true;
			}	
		}
		
		return false;
	}	
	
	public function moveBy($x, $y) { 
		$this->setOption('x', $this->getOption('x') + $x);
		$this->setOption('y', $this->getOption('y') + $y);
	}
	
	public function moveTo($x, $y) { 
		$this->setOption('x', $x);
		$this->setOption('y', $y);
	}
	
	public function scaleTo($width, $height) { 
		$this->setOption('width', $width);
		$this->setOption('height', $height);
	}
	
	public function scaleBy($width, $height) { 
		$this->setOption('width', $this->getOption('width') + $width);		
		$this->setOption('height', $this->getOption('height') + $height);		
	}
	
	public function setBounds($x, $y, $width, $height) { 
		$this->moveTo($x, $y);
		$this->scaleTo($width, $height);
	}
	
	public function getBounds($param = true) { 
		return array(
			'x' => $this['x'],
			'y' => $this['y'],
			'width' => $this['width'],
			'height' => $this['height'],
		);
	}	

}

?>